package com.example.rabbitmq.producer.topic.sender;/**
 * ClassName: TopicSender <br/> Description: <br/> date: 2022/1/24 10:39<br/>
 *
 * @author chenzhian<br />
 * @version
 */

import com.example.common.config.RabbitMQConfig;
import javax.annotation.Resource;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @Author: chenzhian
 * @Date: 2022/1/24 10:39
 * @Description:
 */
@Component
public class TopicSender {

  @Resource
  private RabbitTemplate rabbitTemplate;

  public void send() {
    String context = "topic";
    System.out.println("Sender: " + context);
    rabbitTemplate.convertAndSend(RabbitMQConfig.RABBITMQ_TOPIC_EXCHANGE, "topic.1", context);
  }


  public void send2() {
    String context = "topic2";
    System.out.println("Sender: " + context);
    rabbitTemplate.convertAndSend(RabbitMQConfig.RABBITMQ_TOPIC_EXCHANGE, "topic.a", context);
  }

  public void send3() {
    String context = "topic3";
    System.out.println("Sender: " + context);
    rabbitTemplate.convertAndSend(RabbitMQConfig.RABBITMQ_TOPIC_EXCHANGE, "topic.b", context);
  }
}